package com.yswy.backstage.redislistener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class Subscriber extends Thread {

    //正式环境：47.113.119.244
    //测试环境：132.232.22.222
//    private static final String HOST = "47.113.119.244";
    private static final String HOST = "121.36.168.131";

    Logger log = LoggerFactory.getLogger(Subscriber.class);

    public void setconnect() {
        Jedis jedis = null;
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(0);
        config.setMaxWaitMillis(-1);

        JedisPool pool = new JedisPool(config, HOST, 6379, 0);
        try {

            jedis = pool.getResource();
            jedis.auth("yswy123456");
//            jedis.psubscribe(new KeyExpiredListener(), "__key*__:*");

        } catch (Exception e) {
            e.printStackTrace();
            jedis = pool.getResource();
            jedis.auth("yswy123456");
//            jedis.psubscribe(new KeyExpiredListener(), "__key*__:*");
        } finally {
            jedis.close();

        }


    }

    public void run() {

        setconnect();

    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub


    }

}
